<?
include 'libraries/get_values.php';
include 'libraries/support.php';
function print_header()
{
	$current_site_array = explode("/", $_SERVER['PHP_SELF']);
	$current_site = end($current_site_array);
	$site_title = get_title($current_site);
	?>
	<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">
	<HTML>
	<HEAD>
	<TITLE><? echo "$site_title";?></TITLE>
  <link type="text/css" rel="stylesheet" href="bbogd.css">

	</HEAD>
	<BODY>
	<?
}
function print_footer()
{	?>
	</BODY>
	</HTML>
	<?
}
function print_footline()
{
	$footline_details = get_current_footline();
	?>
	<div id="footline">
	<?echo "{$footline_details['content']}";?>
	<? if (isset($_SESSION['login']))
	{?>
	<BR><A href="auth/logout.php">Log out</A>
	<?};?>
	</div>
	<?
}

function print_event($event_ID,$current_month)
{
	$event_details = get_event_details($event_ID);
	if ($event_details['date'] == "") $date="Planned "; else $date = format_and_extend_date($event_details['date']);
	
	if ($event_details['main_image_ID'] == "") $image_ID=0;
	else
	{
		$image_ID = $event_details['main_image_ID'];
		$image_details = get_image_details($image_ID);
	}
	if ($current_month != get_event_month($event_details['date']))
	{
		if ( $current_month != "") echo "</div>";
		$current_month=get_event_month($event_details['date']);
	?>
	<div id="month">
	<h2 class="event_month"><A>Events in <? echo $current_month; ?></A></h2>
	<?
	}
	?>
	<div id="event" >
		<h3 class="event_title"><?echo "{$event_details['summary']}";?></h3>	
		<?if ($image_ID > 0) echo "<img src='images/{$image_details['image_thumbnail']}' alt='{$image_details['audio_description']}' />";?>
		<p class="event_date"><?echo "$date";?></p>
		<p class="event_content"><?echo "{$event_details['description']}";?></p>
	</div>
	<?if ($image_ID > 0) echo "<br/><br/><br/><br/>";?>
	<?
	return $current_month;
}

function print_navigator()
{
	
	$result = get_current_links();
	?>
	<div id="navigator">
	<h3>Site navigation</h3>
	<ul id="navlist">
	<?
	while ($link_row = mysql_fetch_array($result))
	{
		$link_details = get_link_details($link_row);
		?>
		<li>
		<A href="<?echo "{$link_details['link']}";?>"  title="<?echo "{$link_details['audio_description']}"?>">
		<?echo "{$link_details['title']}";?></A></li>
		<?
	}
	?>
	</ul>
	</div>
	<?
	mysql_free_result($result);

}

function print_headline()
{
	$headline_details = get_current_headline();
	?>
	<div id="headline">
	<h1 class="headline_summary">
	<?echo "{$headline_details['summary']}";?>
	</h1>
	<p class="headline_content">
	<?echo "{$headline_details['content']}";?>
	</p>
	</div>
	<?
}

function print_body()
{
	$body_details = get_current_body();
	if ($body_details != -1)
	{
		if ($body_details['main_image_id'] == "") $image_ID=0;
		else
		{
			$image_ID = $body_details['main_image_id'];
			$image_details = get_image_details($image_ID);
		}
	?>
	<div id="event" >
		<h3 class="event_title"><?echo "{$body_details['summary']}";?></h3>
		<?if ($image_ID > 0) echo "<img src='images/{$image_details['image_thumbnail']}' alt='{$image_details['audio_description']}' />";?>
		<p class="event_content"><?echo "{$body_details['body']}";?></p>
	</div>
	<?
	}

}
function print_fundrising()
{
	$body_details = get_current_body();
	echo $body_details['body'];
}
function print_blog_entry($entry_ID,$current_month)
{
	$entry_details = get_blog_entry_details($entry_ID);
	if ($entry_details['date'] == "" or $entry_details['date']=="0000-00-00") $date="just one day "; else $date = format_and_extend_date($entry_details['date']);
	if ($entry_details['main_image_ID'] == "") $image_ID=0;
	else
	{
		$image_ID = $entry_details['main_image_ID'];
		$image_details = get_image_details($image_ID);
	}
	if ($current_month != get_event_month($entry_details['date']))
	{
		if ( $current_month != "") echo "</div>";
		$current_month=get_event_month($entry_details['date']);
	?>	
	<div id="month">
	<h2 class="event_month"><A>Something from <? echo $current_month; ?> ...</A></h2>
	<?
	}
	?>
	<div id="event" >
		<h3 class="event_title"><?echo "{$entry_details['summary']}";?></h3>	
		<?if ($image_ID > 0) echo "<img src='images/{$image_details['image_thumbnail']}' alt='{$image_details['audio_description']}'  /> <BR/><BR/>";?>
		
		<p class="event_date"><?echo "$date";?></p>
		<p class="event_content"><?echo "{$entry_details['content']}";?></p>
	</div>
	<?
	return $current_month;
}

function print_all_blog_entries()
{
	$all_entries = get_all_active_entries_ID();
	$current_month = "";
	while ($entry_ID = mysql_fetch_array($all_entries))
	{
		$current_month = print_blog_entry($entry_ID['ID'],$current_month);
	}
	mysql_free_result($all_entries);
}
function print_event_image($image_id)
{
	$image_details = get_image_details($image_id);
	$image_filename = $image_details['image'];
	$resized = "tn_med_" . $image_filename;
	if (file_exists("images/" . $resized))
	{
	    $image_filename = $resized;
	}
	echo "<a class='thumbnail' href='#thumb'><img src='images/{$image_details['image_thumbnail']}' border='0' /><span><img src='images/{$image_filename}' /><br />{$image_details['audio_description']}</span></a>";
	

}
function print_gallery_event($event_ID, $current_month)
{
	$gallery_event_details = get_gallery_event_details($event_ID, $current_month);
	if ($gallery_event_details['date'] == "" or $gallery_event_details['date']=="0000-00-00") $date="just one day "; else $date = format_and_extend_date($gallery_event_details['date']);
	
	if ($current_month != get_event_month($gallery_event_details['date']))
	{
		if ( $current_month != "") echo "</div>";
		$current_month=get_event_month($gallery_event_details['date']);
	?>	
	<div id="month">
	<h2 class="event_month"><A>Something from <? echo $current_month; ?> ...</A></h2>
	<?
	}
	
	?>
	<div id="event" > 
	<h3 class="event_title"><?echo "{$gallery_event_details['summary']}";?></h3>	
	<p class="event_date"><?echo "$date";?></p>
	</div>
	<div id="gallerycontainer">
	<?
	$all_images = get_all_event_images_ID($event_ID);
	while ($event_image = mysql_fetch_array($all_images))
	{
		print_event_image($event_image['ID']);
	}
	mysql_free_result($all_images);
	?>
	</div>
	<?
	return $current_month;
	
}
function print_events_and_pictures()
{
	$all_events_with_pictures = get_all_gallery_event_ID();
	$current_month = "";

	while ($event_ID = mysql_fetch_array($all_events_with_pictures))
	{
		$current_month = print_gallery_event($event_ID['id'], $current_month);
	}
	mysql_free_result($all_events_with_pictures);
}
?>
